package com.file.txt.service.impl;

import com.file.txt.service.TxtDataService;
import com.file.xml.pojo.Xml;
import com.file.xml.read.ReaderXml;
import com.file.xml.read.XmlBuilder;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;

@Service
public class TxtDataServiceImpl implements TxtDataService {
    @Override
    public List<Xml> listTxt() throws Exception {
        //读取Resource目录下的XML文件
        Resource resource = new ClassPathResource("TxtUser.txt");
        //利用输入流获取XML文件内容
        BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8));
        StringBuffer buffer = new StringBuffer();
        String line = "";
        while ((line = br.readLine()) != null) {
            buffer.append(line);
        }
        br.close();

        return null;
    }
}
